package com.njitzx.controller;


import com.njitzx.entity.po.PermissionApi;
import com.njitzx.service.PermissionApiService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.njitzx.entity.vo.Result;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import lombok.RequiredArgsConstructor;



import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 权限功能表 前端控制器
 * </p>
 *
 * @author 周鑫
 * @since 2024-08-20
 */
@Api(tags = "权限功能表接口")
@RestController
@RequestMapping("/permission-api")
@RequiredArgsConstructor
public class PermissionApiController {

    private final PermissionApiService permissionApiService;

    @ApiOperation("权限功能表分页查询")
    @GetMapping("/list")
    public Result findPage(@ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
                               @ApiParam("页大小") @RequestParam(defaultValue = "5") Integer pageSize,
                               @ApiParam("查询条件") PermissionApi permissionApi){
        PageInfo<PermissionApi> pageInfo = permissionApiService.findPage(pageNum,pageSize,permissionApi);
        return Result.success(pageInfo);
    }

    @ApiOperation("根据主键查询权限功能表")
    @GetMapping("/{id}")
    public Result findById(@PathVariable Serializable id){
        return Result.success(permissionApiService.findById(id));
    }

    @ApiOperation("新增权限功能表")
    @PostMapping
    public Result add(@RequestBody PermissionApi permissionApi){
        permissionApiService.add(permissionApi);
        return Result.success();
    }

    @ApiOperation("修改权限功能表")
    @PutMapping
    public Result modify(@RequestBody PermissionApi permissionApi){
        permissionApiService.modify(permissionApi);
        return Result.success();
    }

    @ApiOperation("根据主键删除权限功能表")
    @DeleteMapping("/{id}")
    public Result removeById(@PathVariable Serializable id){
        permissionApiService.removeById(id);
        return Result.success();
    }

}
